package com.ruoyi.school.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.school.domain.CourseinfoStage;
import com.ruoyi.school.service.ICourseinfoStageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专业课详情阶段Controller
 * 
 * @author admin
 * @date 2023-08-31
 */
@RestController
@RequestMapping("/school/stage")
public class CourseinfoStageController extends BaseController
{
    @Autowired
    private ICourseinfoStageService courseinfoStageService;

    /**
     * 查询专业课详情阶段列表
     */
    @PreAuthorize("@ss.hasPermi('school:stage:list')")
    @GetMapping("/list")
    public TableDataInfo list(CourseinfoStage courseinfoStage)
    {
        startPage();
        List<CourseinfoStage> list = courseinfoStageService.selectCourseinfoStageList(courseinfoStage);
        return getDataTable(list);
    }

    /**
     * 导出专业课详情阶段列表
     */
    @PreAuthorize("@ss.hasPermi('school:stage:export')")
    @Log(title = "专业课详情阶段", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseinfoStage courseinfoStage)
    {
        List<CourseinfoStage> list = courseinfoStageService.selectCourseinfoStageList(courseinfoStage);
        ExcelUtil<CourseinfoStage> util = new ExcelUtil<CourseinfoStage>(CourseinfoStage.class);
        util.exportExcel(response, list, "专业课详情阶段数据");
    }

    /**
     * 获取专业课详情阶段详细信息
     */
    @PreAuthorize("@ss.hasPermi('school:stage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(courseinfoStageService.selectCourseinfoStageById(id));
    }

    /**
     * 新增专业课详情阶段
     */
    @PreAuthorize("@ss.hasPermi('school:stage:add')")
    @Log(title = "专业课详情阶段", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseinfoStage courseinfoStage)
    {
        return toAjax(courseinfoStageService.insertCourseinfoStage(courseinfoStage));
    }

    /**
     * 修改专业课详情阶段
     */
    @PreAuthorize("@ss.hasPermi('school:stage:edit')")
    @Log(title = "专业课详情阶段", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourseinfoStage courseinfoStage)
    {
        return toAjax(courseinfoStageService.updateCourseinfoStage(courseinfoStage));
    }

    /**
     * 删除专业课详情阶段
     */
    @PreAuthorize("@ss.hasPermi('school:stage:remove')")
    @Log(title = "专业课详情阶段", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(courseinfoStageService.deleteCourseinfoStageByIds(ids));
    }
}
